<?php if (!defined('THINK_PATH')) exit();?><!doctype html>
<html>
<head>
	<meta charset="utf-8">
	<!-- Set render engine for 360 browser -->
	<meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">

    <!-- HTML5 shim for IE8 support of HTML5 elements -->
    <!--[if lt IE 9]>
      <script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
    <![endif]-->

	<link href="/public/simpleboot/themes/<?php echo C('SP_ADMIN_STYLE');?>/theme.min.css" rel="stylesheet">
    <link href="/public/simpleboot/css/simplebootadmin.css" rel="stylesheet">
    <link href="/public/js/artDialog/skins/default.css" rel="stylesheet" />
    <link href="/public/simpleboot/font-awesome/4.4.0/css/font-awesome.min.css"  rel="stylesheet" type="text/css">
    <style>
		.length_3{width: 180px;}
		form .input-order{margin-bottom: 0px;padding:3px;width:40px;}
		.table-actions{margin-top: 5px; margin-bottom: 5px;padding:0px;}
		.table-list{margin-bottom: 0px;}
	</style>
	<!--[if IE 7]>
	<link rel="stylesheet" href="/public/simpleboot/font-awesome/4.4.0/css/font-awesome-ie7.min.css">
	<![endif]-->
<script type="text/javascript">
//全局变量
var GV = {
    DIMAUB: "/",
    JS_ROOT: "public/js/",
    TOKEN: ""
};
document.domain = "xinhuiwen.com";
</script>
<!-- Le javascript
    ================================================== -->
    <!-- Placed at the end of the document so the pages load faster -->
    <script src="/public/js/jquery.js"></script>
    <script src="/public/js/wind.js"></script>
    <script src="/public/js/publish.js"></script>

    <script src="/public/simpleboot/bootstrap/js/bootstrap.min.js"></script>
<?php if(APP_DEBUG): ?><style>
		#think_page_trace_open{
			z-index:9999;
		}
	</style><?php endif; ?>

<script src="/public/js/common.js"></script>

</head>
<body>
<div class="wrap">
    <form method="post" class="form-horizontal " id="myform"  action="<?php echo U('Admin/Area/liverolePost');?>">
        <div class="containerr">

            <div style="width: 600px; margin-left: 20px; margin-bottom: 15px;">
                <span style="width: 80px; margin-top: 5px; float: left;">直播权限 </span>
                <select id="live_status" class="select_2" name="live_status">
                    <option <?php if($live_status == 0): ?>selected<?php endif; ?> value="0">关闭</option>
                    <option <?php if($live_status == 1): ?>selected<?php endif; ?> value="1">开启</option>
                </select>
            </div>
            <div class="span3" style="width: 630px;">
                <span style="width: 80px; margin-top: 10px; float: left;">设置管理员 </span>
                <input type="hidden" name="column_id" id="column_id" value="<?php echo $column_id;?>">
                <input type="hidden" name="admin_hidden_ids" id="admin_hidden_ids"  value="<?php echo $live_ids_arr ? implode(',',$live_ids_arr).',' : '';?>">
                <input type="hidden" name="column_type" id="column_type"  value="<?php echo $column_type ? $column_type : 0;?>">

                <input type="text"  style="width: 500px; float: left;" name="administrators" id="administrator" readonly="readonly" value="<?php if($live_status == 1) echo $live_arr ? implode(',',$live_arr).',' : '';?>">
            </div>

        </div>

        <div class="control-group" style="margin-top: 50px;">
            <label class="span1 control-label" style="width: 90px;"></label>
            <div class="span3">
                <?php if(is_array($arr_mer)): foreach($arr_mer as $admin_key=>$admin_value): ?><input  admin_name="<?php echo ($admin_value); ?>" name="admin_checkbox"  type="checkbox" value="<?php echo ($admin_key); ?>" <?php if(in_array($admin_key,$live_ids_arr) && $live_status == 1) echo 'checked="checked"'; ?> /><?php echo ($admin_value); ?><br/><?php endforeach; endif; ?>
            </div>
        </div>


        <div class="form-actions" style="padding-left:260px;">
            <a class="btn btn-primary" id="ajaxform">提 交</a>
            &nbsp;&nbsp;<a class="btn" id="ajaxback"><?php echo L('BACK');?></a>
        </div>
    </form>
</div>

<script type="text/javascript" src="/public/js/content_addtop.js"></script>
<script type="text/javascript" src="/public/js/ueditor/ueditor.config.js"></script>
<script type="text/javascript" src="/public/js/ueditor/ueditor.all.min.js"></script>
<script type="text/javascript"
        src="http://ajax.aspnetcdn.com/ajax/jquery.validate/1.10.0/jquery.validate.min.js"></script>
<script src="/public/js/layer/layer.js"></script>
<script type="text/javascript">
    $(function(){
        $("[name='admin_checkbox']").click(function(){
            var admin_id = $(this).val();
            var admin_name = $(this).attr('admin_name');

            var admin_hidden_ids = $("#admin_hidden_ids").val();
            var admin_values = $("#administrator").val();

            var ids_arr = admin_hidden_ids.split(",");
            var values_arr = admin_values.split(",");


            if(ids_arr.indexOf(admin_id) == '-1'){

                admin_hidden_ids+=admin_id+',';
                admin_values+=admin_name+',';
                $("#administrator").val(admin_values);
                $("#admin_hidden_ids").val(admin_hidden_ids);
            }else{

                $.each(ids_arr,function(index,item){

                    if(item==admin_id){
                        ids_arr.splice(index,1);
                        values_arr.splice(index,1);
                    }
                })
                admin_hidden_ids = ids_arr.join(",");
                admin_values = values_arr.join(",");
                $("#administrator").val(admin_values);
                $("#admin_hidden_ids").val(admin_hidden_ids);
            }
        })
    })


    // ajax 提交表单
    $(document).ready(function(){
        $("#ajaxform").click(function(){    // 提交按钮触发事件
            var tourl = $("#myform").attr("action");    // 获取 表单的 提交地址
            var column_id = $("#column_id").val();
            var admin_hidden_ids = $("#admin_hidden_ids").val();
            var live_status      = $("#live_status").val();
            var column_type      = $("#column_type").val();

            $.post(tourl,{admin_hidden_ids:admin_hidden_ids,column_id:column_id,live_status:live_status,column_type:column_type},function(result){
                if(result == '1'){
                    var msg = '编辑成功';
                }else{
                    var msg = '编辑失败';
                }

                parent.layer.msg(msg,{time:2000},1,function(a){

                });
                setTimeout(function(){
                    var index = parent.layer.getFrameIndex(window.name); //获取窗口索引
                    parent.layer.close(index);
                }, 1000);
            });
        });
        $("#ajaxback").click(function(){
            var index = parent.layer.getFrameIndex(window.name); //获取窗口索引
            parent.layer.close(index);
        });
    });
</script>
</body>
</html>